//
//  BaiKeMainCell.m
//  BaseProject
//
//  Created by mac on 2020/12/21.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "BaiKeMainCell.h"
#import "BaiKeMainModel.h"
@interface BaiKeMainCell ()
@property(nonatomic,strong)UIView *bgVIew;
@property(nonatomic,strong)UILabel *titleLab;
@property(nonatomic,strong)UILabel *timeLab;
@property(nonatomic,strong)YYLabel *contentLab;
@property(nonatomic,strong)UIImageView *leftTopIV;
@property(nonatomic,strong)UIImageView *rightIV;
@end

@implementation BaiKeMainCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = WhiteColor;
        self.contentView.backgroundColor = WhiteColor;
        
    }
    return self;
}
- (void)setListModel:(BaiKeSubListDataListModel *)listModel
{
    _listModel = listModel;
    [self bgVIew];
    [self leftTopIV];
    [self rightIV];
    
    self.titleLab.text = listModel.title;
    self.timeLab.text = listModel.createTime;
    self.contentLab.attributedText = listModel.briefIntroduction_attributes;
    //frame
    self.contentLab.height = listModel.introductionHeight;
    self.bgVIew.height = listModel.cellHeight - 10*ADAPTER_WIDTH;
}
#pragma mark - lazy懒加载
- (UIView *)bgVIew
{
    if (!_bgVIew) {
        UIView *iv = [[UIView alloc]init];
        [self addSubview:iv];
        iv.frame = CGRectMake(14*ADAPTER_WIDTH, 10*ADAPTER_WIDTH, WIDTH - 28*ADAPTER_WIDTH, 109*ADAPTER_WIDTH);
        iv.layer.cornerRadius = 6*ADAPTER_WIDTH;
        iv.layer.masksToBounds = YES;
        iv.backgroundColor = rgba(247, 248, 250, 1);
        _bgVIew = iv;
    }
    return _bgVIew;
}
- (UILabel *)titleLab
{
    if (!_titleLab) {
        UILabel *lab = [[UILabel alloc]init];
        [self.bgVIew addSubview:lab];
        lab.font = [UIFont systemFontOfSize:14*ADAPTER_WIDTH weight:UIFontWeightMedium];
        lab.textColor = kColor51;
        lab.textAlignment = NSTextAlignmentLeft;
        lab.numberOfLines = 1;
        lab.frame = CGRectMake(12*ADAPTER_WIDTH, 10*ADAPTER_WIDTH, 200*ADAPTER_WIDTH, 20*ADAPTER_WIDTH);
        _titleLab = lab;
    }
    return _titleLab;
}
- (UILabel *)timeLab
{
    if (!_timeLab) {
        UILabel *lab = [[UILabel alloc]init];
        [self.bgVIew addSubview:lab];
        lab.font = [UIFont systemFontOfSize:12*ADAPTER_WIDTH weight:UIFontWeightRegular];
        lab.textColor = rgba(153, 153, 153, 1);
        lab.textAlignment = NSTextAlignmentRight;
        lab.numberOfLines = 1;
        lab.frame = CGRectMake(self.bgVIew.width - 162*ADAPTER_WIDTH, 12*ADAPTER_WIDTH, 150*ADAPTER_WIDTH, 17*ADAPTER_WIDTH);
        _timeLab = lab;
    }
    return _timeLab;
}
- (YYLabel *)contentLab
{
    if (!_contentLab) {
        YYLabel *lab = [[YYLabel alloc]init];
        [self.bgVIew addSubview:lab];
        lab.font = [UIFont systemFontOfSize:13*ADAPTER_WIDTH weight:UIFontWeightRegular];
        lab.textColor = rgba(102, 102, 102, 1);
        lab.textAlignment = NSTextAlignmentLeft;
        lab.numberOfLines = 0;
        lab.frame = CGRectMake(12*ADAPTER_WIDTH, 35*ADAPTER_WIDTH,self.bgVIew.width - 24*ADAPTER_WIDTH, 0);
        _contentLab = lab;
    }
    return _contentLab;
}
- (UIImageView *)leftTopIV
{
    if (!_leftTopIV) {
        UIImageView *iv = [[UIImageView alloc]init];
        [self.bgVIew addSubview:iv];
        iv.image = [UIImage getPNGimageInBundleWithName:@"BaiKe_?"];
        iv.frame = CGRectMake(6*ADAPTER_WIDTH, 4*ADAPTER_WIDTH, 15*ADAPTER_WIDTH, 14*ADAPTER_WIDTH);
        _leftTopIV = iv;
    }
    return _leftTopIV;
}
- (UIImageView *)rightIV
{
    if (!_rightIV) {
        UIImageView *iv = [[UIImageView alloc]init];
        [self.bgVIew addSubview:iv];
        iv.image = [UIImage getPNGimageInBundleWithName:@"BaiKe_san"];
        [iv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(143*ADAPTER_WIDTH, 109*ADAPTER_WIDTH));
            make.bottom.right.mas_equalTo(0);
        }];
        _rightIV = iv;
    }
    return _rightIV;
}
@end
